#ifndef DW_GRAPHICS_INDEX_BUFFER_INL
#	define DW_GRAPHICS_INDEX_BUFFER_INL

#include "graphics/opengl/bufferobject.h"

namespace dw {
	namespace graphics {

inline IndexBuffer::indextypes IndexBuffer::getIndexType() const
{
	return m_indexType;
}

inline IndexBuffer::IndexBuffer(updates update, usages usage, indextypes indexType)
:	super(type_index, update, usage)
,	m_indexType(indexType)
{
	super::setElementSize(glIndexSize(m_indexType));
}

inline IndexBuffer::IndexBuffer(GLuint id, updates update, usages usage, indextypes indexType)
:	super(id, type_index, update, usage)
,	m_indexType(indexType)
{
	super::setElementSize(glIndexSize(m_indexType));
}

inline IndexBuffer::~IndexBuffer()
{
}

/*static*/ inline GLsizei IndexBuffer::glIndexSize(indextypes indexType)
{
	static const GLsizei glSizes[indextypes_count] = {
		sizeof (dw::uint8),
		sizeof (dw::uint16),
		sizeof (dw::uint32)
	};

	return glSizes[indexType];
}

/*static*/ inline  GLenum IndexBuffer::glType(indextypes indexType)
{
	static const GLenum glTypes[indextypes_count] = {
		GL_UNSIGNED_BYTE,
		GL_UNSIGNED_SHORT,
		GL_UNSIGNED_INT
	};

	return glTypes[indexType];
}

	} // namespace graphics
} // namespace dw

#endif // !DW_GRAPHICS_INDEX_BUFFER_INL
